﻿#region License statement
// NJamb, a specification and delta-specification DSL
// Copyright (c) 2010-2011, Mark Knell
// Published under the MIT License; all other rights reserved
#endregion

#region using...
using System;
using NJamb.Parser.SpecificationBuilders.SubjectHas.Simple.Singular;
using NJamb.Parser.SpecificationBuilders.SubjectIs.Simple.Singular;
using NJamb.Specifications.Simple.Singular;
using Stile.Patterns.SelfDescribingPredicates;
#endregion

namespace NJamb.Parser.Subjects.Singular
{
    public class SingularSubject<TSubject> :
        Subject<TSubject, ISingularHas<TSubject>, INegatableSingularIs<TSubject>, ISingularSpecification<TSubject>>,
        ISingularSubject<TSubject>
    {
        public SingularSubject(Func<TSubject> getter, Lazy<string> lazyDescription)
            : base(getter, lazyDescription) {}

        public override ISingularSpecification<TSubject> Specify(ISelfDescribingPredicate<TSubject> selfDescribingPredicate,
            Func<Exception, TSubject, IEvaluation<TSubject>> exceptionFilter = null)
        {
            return new SingularSpecification<TSubject>(this, selfDescribingPredicate, exceptionFilter : exceptionFilter);
        }

        protected override ISingularHas<TSubject> MakeHas()
        {
            return new SingularHas<TSubject>(this);
        }

        protected override INegatableSingularIs<TSubject> MakeIs()
        {
            return new NegatableSingularIs<TSubject>(this, Negated.False);
        }
    }
}
